package cn.itsource.hrm.controller;

import cn.itsource.hrm.util.RedisUtils;
import cn.itsource.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

//暴露一个接口名称
@RestController
@RequestMapping("/redis")
public class RedisController {
    @PostMapping("/set")
//    @RequestParam:从请求中获取值
    public AjaxResult set(@RequestParam("key") String key , @RequestParam("value") String value){
        RedisUtils.INSTANCE.set(key,value);
        return AjaxResult.me();
    }
    @GetMapping("/get/{key}")
//    @RequestParam:从请求中获取值
    public AjaxResult get(@PathVariable("key") String key ){
        String result = RedisUtils.INSTANCE.get(key);
//        将结果以json的格式返回
        return AjaxResult.me().setResultObj(result);

    }
}
